$(function(){
	$('.form_datetime').datetimepicker({
		format: 'yyyy-mm-dd',
		language:  'zh-CN',
	    weekStart: 1,
	    todayBtn:  1,
	    autoclose: 1,
	    todayHighlight: 1,
	    startView: 2,
	    minView: 2,
	    forceParse: 1
	});	
	$("#querybtn").bind("click",function(){
		var param = {};
		param.taskName = $("#taskName").val().trim();
		param.createTimeBegin = $("#createTimeBegin").val().trim();
		param.createTimeEnd = $("#createTimeEnd").val().trim();
		main_page("queryTaskLogByPage.do",param,callback,$("#pageFoot"));
	});
});


function callback(data){
    $("#data_body").empty();
    for (var i = 0; i < data.length; i++) {
        var obj = data[i];
        var $tr = $("<tr></tr>");
        var $td = $("<td></td>");
        $tr.append($td.clone().text(obj.taskName));
        $tr.append($td.clone().text(obj.createTime));
        $tr.append($td.clone().text(obj.addStarNum));
        $tr.append($td.clone().text(obj.note?obj.note:""));
        var detailBtn = $("<button type='button' class='btn btn-default btn-xs' data-toggle='modal' data-target='#log_modal'>详情</button>");
        $tr.append($td.clone().append(detailBtn));
        $tr.appendTo($("#data_body"));
        detailBtn.bind("click",obj, function (e) {
            var obj = e.data;
            $("#log_modal_title").html(obj.taskName+"<br>"+obj.createTime);
            $("#log_modal_content").html(obj.note?("addStarNum:"+obj.addStarNum+"<br>note:<br>"+obj.note):"");
        });
    }
}
